{include file="public/header" title="课程评估"/}
<!-- start page -->
<div class="container bs-docs-container">
    <div class="row">
        <!-- 左侧导航栏 start -->
        {include file="Public/sidebar"/}
        <!-- 左侧导航栏 end -->
        <div class="col-lg-10 col-md-10 col-sm-8">
            <div class="page-header">
                <h2 class="titleh">课程列表</h2>
            </div>
            <div class="content">
                <form>
                    <table class="table table-striped table-hover table-condensed" id="trees_list_table">
                        <thead>
                        <tr>
                            <th class="col-md-1 text-center">ID</th>
                            <th class="col-md-1 text-center">课程名</th>
                            <th class="col-md-1 text-center">评估分数</th>
                        </tr>
                        </thead>
                        <tbody>
                            {if condition="$lesson_list"}
                            {foreach name="lesson_list" item="vo" }
                            <tr>
                                <td class="col-md-1 text-center">
                                    {$vo.Id}
                                    <input type="hidden" value="{$vo.Id}" class="lesson_id">
                                </td>
                                <td class="col-md-1 text-center">{$vo.name}</td>
                                <td class="col-md-3 text-center">
                                    {for start="1" end="6" name="i"}
                                    <div class="radio col-md-2 col-lg-2 col-sm-5" style="margin-top: 0px;margin-bottom: 0px">
                                        <label>
                                            <input type="radio" value="{$i}" name="assess_{$vo.Id}"
                                            {if condition="$i eq check_assess($vo['Id'])"}checked{/if}>
                                            {$i}
                                        </label>
                                    </div>
                                    {/for}
                                </td>
                            </tr>
                            {/foreach}
                            {else/}
                            <tr>
                                <td colspan="13">暂无相关成绩信息</td>
                            </tr>
                            {/if}
                        </tbody>
                    </table>
                    <input type="hidden" value="{$std_id}" id="std_id">
                    <button type="button" class="btn btn-primary" id="btn-sumbit">提交</button>
                    <p id="sumbit_warning" class="text-success"></p>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    $("#lesson_assess").addClass("active");
    var lesson_list="";
    var assess_list="";
    var lesson_id=0;
    $("#btn-sumbit").click(function()
    {
        if(get_array()!=0)
        {
            $.ajax({
                type: "post",
                url: "__APP__/home/lesson/set_assess",
                async: true,
                data: {
                    std_id: $("#std_id").val(),
                    lesson_list:lesson_list,
                    assess_list:assess_list
                },
                datatype: "json",
                success: function (data) {
                    if(data.status==0)
                    {
                        $("#sumbit_warning").html("评估提交成功")
                    }
                    else
                    {
                        $("#sumbit_warning").html(data.info)
                        return false
                    }
                },
                error:function(data)
                {
                    $("#sumbit_warning").html("网络异常，请刷新重试")
                    return false
                }
            })
        }
    });
    function get_array()
    {
        var a=0;
        lesson_list=""
        assess_list=""
        $(".lesson_id").each(function(){
            lesson_id=$(this).val()
            lesson_list+=lesson_id+",";
            var item = $("input[name='assess_"+lesson_id+"']:checked");
            var len=item.length;
            if(len>0) {
                assess_list+=item.val()+",";
                a=1;
            }
            else
            {
                alert("编号为："+lesson_id+"的课程尚未打分！");
                a=0
                return false;
            }
        });
        return a;
    }
</script>
{include file="public/footer"/}